﻿.transition(@timeout, @prop) {
    -moz-transition: @timeout @prop;
    -o-transition: @timeout @prop;
    -webkit-transition: @timeout @prop;
    transition: @timeout @prop;
}

.border-box() {
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

.text-ellipsis() {
    -ms-text-overflow: ellipsis;
    -o-text-overflow: ellipsis;
    text-overflow: ellipsis;
    overflow: hidden;
    -ms-word-break: keep-all;
    word-break: keep-all;
    -ms-word-wrap: initial;
    word-wrap: initial;
}

.tinyselect-container {
    background-color: #FEFEFE;
    border: 1px solid #ababab;
    height: auto;
    color: #333;
    .border-box();
    &:not(.tinyselect-list-mode) {
        border-top-width: 0;
        box-shadow: rgba(0, 0, 0, .2) 0 2px 4px 2px;
    }
    .tinyselect-box {
        overflow-y: auto;
        .tinyselect-item {
            .border-box();
            cursor: default;
            .text-ellipsis();
            border: 1px solid transparent;
            border-top-color: #FFF;
            .transition( 618ms, border-color);
            .transition( 618ms, background-color);
            position: relative;
            padding: 0 5px;
            &-before {
                float: left;
            }
            &-text {
                float: left;
            }
            &-after {
                float: right;
            }
            &-hover {
                border-color: #1773B6;
            }
            &-selected {
                color: #1773B6;
                background-color: #DFF2FF;
                .tinyselect-item-after {
                    width: 16px;
                    height: 100%;
                    text-align: center;
                    &:after {
                        width: 13px;
                        height: 9px;
                        display: inline-block;
                        content: ' ';
                        background: url(./img/selected.png) no-repeat center center;
                    }
                }
            }
        }
    }
    .tinyselect-header {
        border-bottom: 1px solid #CCC;
        .tinyselect-filter {
            border: none;
            width: 100%;
            height: 28px;
            padding: 0 2px;
            .border-box();
        }
    }
    .tinyselect-footer {
        font-size: smaller;
        padding: 2px 5px;
        border-top: 1px solid #EEE;
        &:after {
            content: ' ';
            clear: both;
            display: block;
        }
        &-left {
            display: block;
            float: left;
        }
        &-right {
            display: block;
            float: right;
        }
    }
    &-empty {
        .tinyselect-header,
        .tinyselect-footer {
            display: none !important;
        }
        .tinyselect-box {
            color: #888;
        }
    }
}

.tinyselect-context {
    .border-box();
    &-result {
        height: inherit;
        overflow-y: auto;
        .tinyselect-result-item {
            display: block;
            .text-ellipsis();
            max-width: 160px;
            min-width: 100px;
            margin: 2px 5px;
            background-color: #DAEAF9;
            color: #3D7399;
            float: left;
            height: 24px;
            line-height: 24px;
            border-radius: 12px;
            &-text {
                display: block;
                max-width: 120px;
                min-width: 60px;
                .text-ellipsis();
                padding: 0 5px;
                float: left;
                height: 24px;
                line-height: 24px;
            }
            &-link {
                display: block;
                width: 24px;
                text-align: center;
                cursor: pointer;
                float: right;
                height: 24px;
                line-height: 23px;
                border-radius: 12px;
                color: #FFF;
                background: url(./img/remove.png) no-repeat center center;
            }
        }
    }
    &-with-dropdown {
        .tinyselect-context-result {
            padding-right: 36px;
        }
        .tinyselect-context-dropdown {
            position: absolute;
            right: 0;
            top: 0;
            width: 36px;
            height: 100%;
            background: url(./img/arrow.png) center center no-repeat;
            .transition( 618ms, background-color);
        }
    }
    &.tinyselect-context-readonly {
        .tinyselect-result-item-link {
            background-color: lighten(#ec4c64, 30%);
            cursor: initial;
        }
        &.tinyselect-context-with-dropdown .tinyselect-context-dropdown {
            background-color: lighten(#CFCFCF, 10%);
        }
    }
    &:not(.tinyselect-context-readonly) {
        .tinyselect-result-item-link {
            background-color: #ec4c64;
            cursor: pointer;
            &:hover {
                background-color: #e67c7c;
            }
        }
        &.tinyselect-context-with-dropdown .tinyselect-context-dropdown {
            background-color: #CFCFCF;
            cursor: pointer;
            &:hover {
                background-color: darken(#CFCFCF, 10%);
            }
        }
    }
}